class Panel extends PIXI.Container {
	constructor(panelName, size) {
		super();

		// 绘制底板
		const frame = new PIXI.smooth.SmoothGraphics();
		frame.beginFill(0x0000FF, 0.5);
		frame.drawRect(0, 0, size.width, size.height);
		frame.endFill();
		super.addChild(frame);

		// 绘制底部
		const splitMask = new PIXI.smooth.SmoothGraphics();
		splitMask.beginFill(0xE8F880, 1);
		splitMask.drawRect(1, 1, size.width-2, 1);
		splitMask.endFill();

		const split = new PIXI.smooth.SmoothGraphics();
		split.beginFill(0xA8B848, 1);
		split.lineStyle({ color: 0x000000, width: 1, alignment: 0 });
		split.drawRect(0, size.height-8, size.width, 8);
		split.endFill();
		split.addChild(splitMask);
		super.addChild(split);

		// 绘制头部
		const headLiteral = panelName;
		const headText = new PIXI.Text(headLiteral, panelHeadStyle);
		headText.x = 20;
		headText.y = 2;
		headText.resolution = 2;

		const headMask = new PIXI.smooth.SmoothGraphics();
		headMask.lineStyle({ color: 0x707020, width: 1, alignment: 0 });
		headMask.beginFill(0xE8F880, 0);
		headMask.drawRect(1, 1, size.width-2, 19);
		headMask.endFill();

		const head = new PIXI.smooth.SmoothGraphics();
		head.beginFill(0xA8B848, 1);
		head.lineStyle({ color: 0x000000, width: 1, alignment: 0 });
		head.drawRect(0, 0, size.width, 21);
		head.endFill();
		head.addChild(headMask);
		head.addChild(splitMask);
		head.addChild(headText);
		super.addChild(head);
	}

	addChild(child) {
		var y = 24;
		for(var i = 3;i < this.children.length; i++)
			y = y + this.children[i].height + 1;

		child.y = y;
		super.addChild(child);
	}
}
